/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package projetobittencourt1;
/**
 *
 * @author cliente
 */

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

public class GameObjectFactory
{
    
    public void loadObjectDocument(String xmlFileName)
    {
        URL url = getClass().getResource(xmlFileName);
        File file = new File(url.getPath().replace("%20", " "));

        SAXBuilder sb = new SAXBuilder();
        sb.setIgnoringBoundaryWhitespace(true);
        try {

            Document xmlDocument = sb.build(file);

            Element root = xmlDocument.getRootElement();
            List elementos = root.getChildren();

            Iterator i = elementos.iterator();

            while(i.hasNext())
            {
                Element e = (Element) i.next();
                System.out.println("Documento " + e.getName());
                System.out.println("Documento " + e.getChildText(xmlFileName));
            }

        } catch (JDOMException ex) {
            Logger.getLogger(GameObjectFactory.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(GameObjectFactory.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
